#include <bits/stdc++.h>
using namespace std;
struct Car
{
    long long d,v,a;
};
Car car[100010];
long long T,n,m,L,V,cam[100010],d1[100010],d2[100010];
int main()
{
    freopen("r","detect.in",stdin);
    freopen("w","detect.out",stdout);
    cin>>T;
    for(int r=1;r<=T;r++)
    {
        long long mfcam=0,ans1=0,ans2=0;
        cin>>n>>m>>L>>V;
        for(int i=1;i<=n;i++) cin>>car[i].d>>car[i].v>>car[i].a;
        for(int i=1;i<=m;i++)
        {
            cin>>cam[i];
            mfcam=max(mfcam,cam[i]);
        }
        for(int i=1;i<=n;i++)
        {
            long long add=0;
            if(car[i].a!=0) add=(V*V-car[i].v*car[i].v)/(2*car[i].a);
            if(add<=0) add=0;
            else add=(V*V-car[i].v*car[i].v+2*car[i].a-1)/(2*car[i].a);
            if(car[i].d+add<=mfcam) ans1++;
        }
        if(ans1!=0) ans2=m-1;
        else ans2=m;
        cout<<ans1<<' '<<ans2<<'\n';
    }
    return 0;
}
